/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: nu uc
 * License Type: Evaluation
 */
package org.testis.orm.classes;

import org.orm.*;

public class T_dmap_abstract_objects {
    public T_dmap_abstract_objects() {
    }

    public boolean save() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .saveObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean delete() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .deleteObject(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean refresh() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().refresh(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean evict() throws PersistentException {
	try {
	    org.testis.orm.manager.TestisDbPersistentManager.instance()
		    .getSession().evict(this);
	    return true;
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate() throws PersistentException {
	try {
	    if (getDeviceAbstraction() != null) {
		getDeviceAbstraction().t_dmap_abstract_objects.remove(this);
	    }

	    org.testis.orm.classes.T_dmap_abstraction_pair[] lT_dmap_abstraction_pairs = t_dmap_abstraction_pair
		    .toArray();
	    for (int i = 0; i < lT_dmap_abstraction_pairs.length; i++) {
		lT_dmap_abstraction_pairs[i].setAbstract(null);
	    }
	    return delete();
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    public boolean deleteAndDissociate(org.orm.PersistentSession session)
	    throws PersistentException {
	try {
	    if (getDeviceAbstraction() != null) {
		getDeviceAbstraction().t_dmap_abstract_objects.remove(this);
	    }

	    org.testis.orm.classes.T_dmap_abstraction_pair[] lT_dmap_abstraction_pairs = t_dmap_abstraction_pair
		    .toArray();
	    for (int i = 0; i < lT_dmap_abstraction_pairs.length; i++) {
		lT_dmap_abstraction_pairs[i].setAbstract(null);
	    }
	    try {
		session.delete(this);
		return true;
	    } catch (Exception e) {
		return false;
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw new PersistentException(e);
	}
    }

    private java.util.Set this_getSet(int key) {
	if (key == org.testis.orm.manager.ORMConstants.KEY_T_DMAP_ABSTRACT_OBJECTS_T_DMAP_ABSTRACTION_PAIR) {
	    return ORM_t_dmap_abstraction_pair;
	}

	return null;
    }

    private void this_setOwner(Object owner, int key) {
	if (key == org.testis.orm.manager.ORMConstants.KEY_T_DMAP_ABSTRACT_OBJECTS_DEVICEABSTRACTION) {
	    this.DeviceAbstraction = (org.testis.orm.classes.T_bed_deviceabstraction) owner;
	}
    }

    org.orm.util.ORMAdapter _ormAdapter = new org.orm.util.AbstractORMAdapter() {
	public java.util.Set getSet(int key) {
	    return this_getSet(key);
	}

	public void setOwner(Object owner, int key) {
	    this_setOwner(owner, key);
	}

    };

    private String name;

    private org.testis.orm.classes.T_bed_deviceabstraction DeviceAbstraction;

    private int id;

    private java.util.Set ORM_t_dmap_abstraction_pair = new java.util.HashSet();

    public void setName(String value) {
	this.name = value;
    }

    public String getName() {
	return name;
    }

    private void setId(int value) {
	this.id = value;
    }

    public int getId() {
	return id;
    }

    public int getORMID() {
	return getId();
    }

    public void setDeviceAbstraction(
	    org.testis.orm.classes.T_bed_deviceabstraction value) {
	if (DeviceAbstraction != null) {
	    DeviceAbstraction.t_dmap_abstract_objects.remove(this);
	}
	if (value != null) {
	    value.t_dmap_abstract_objects.add(this);
	}
    }

    public org.testis.orm.classes.T_bed_deviceabstraction getDeviceAbstraction() {
	return DeviceAbstraction;
    }

    /**
     * This method is for internal use only.
     */
    private void setORM_DeviceAbstraction(
	    org.testis.orm.classes.T_bed_deviceabstraction value) {
	this.DeviceAbstraction = value;
    }

    private org.testis.orm.classes.T_bed_deviceabstraction getORM_DeviceAbstraction() {
	return DeviceAbstraction;
    }

    private void setORM_T_dmap_abstraction_pair(java.util.Set value) {
	this.ORM_t_dmap_abstraction_pair = value;
    }

    private java.util.Set getORM_T_dmap_abstraction_pair() {
	return ORM_t_dmap_abstraction_pair;
    }

    public final org.testis.orm.classes.T_dmap_abstraction_pairSetCollection t_dmap_abstraction_pair = new org.testis.orm.classes.T_dmap_abstraction_pairSetCollection(
	    this,
	    _ormAdapter,
	    org.testis.orm.manager.ORMConstants.KEY_T_DMAP_ABSTRACT_OBJECTS_T_DMAP_ABSTRACTION_PAIR,
	    org.testis.orm.manager.ORMConstants.KEY_T_DMAP_ABSTRACTION_PAIR_ABSTRACT,
	    org.testis.orm.manager.ORMConstants.KEY_MUL_ONE_TO_MANY);

    public String toString() {
	return toString(false);
    }

    public String toString(boolean idOnly) {
	if (idOnly) {
	    return String.valueOf(getId());
	} else {
	    StringBuffer sb = new StringBuffer();
	    sb.append("T_dmap_abstract_objects[ ");
	    sb.append("Name=").append(getName()).append(" ");
	    if (getDeviceAbstraction() != null)
		sb.append("DeviceAbstraction.Persist_ID=")
			.append(getDeviceAbstraction().toString(true))
			.append(" ");
	    else
		sb.append("DeviceAbstraction=null ");
	    sb.append("Id=").append(getId()).append(" ");
	    sb.append("T_dmap_abstraction_pair.size=")
		    .append(t_dmap_abstraction_pair.size()).append(" ");
	    sb.append("]");
	    return sb.toString();
	}
    }

}
